using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Nihonaid.classes
{
    class Configuration
    {
        public static int item_treshold = 25;
        public static int todays_items = 25;
        public static DateTime last_session_date = DateTime.Now;
        public static int scheduler = 0;
        public static int milestone1 = -1;
        public static int milestone2 = -1;
        public static int milestone3 = -1;
        public static int milestone4 = -1;
        public static int milestone5 = -1;
        public static int milestone6 = -1;
        public static int milestone7 = -1;
        public static int milestone8 = -1;

        /// <summary>
        /// Loads the configuration from persistent storage
        /// </summary>
        public static void Load()
        {
            StreamReader reader = new StreamReader(new FileStream(Application.StartupPath + "\\Nihonaid.config", FileMode.Open));
            item_treshold = int.Parse(reader.ReadLine().Trim());
            todays_items = int.Parse(reader.ReadLine().Trim());
            last_session_date = DateTime.Parse(reader.ReadLine().Trim());
            scheduler = int.Parse(reader.ReadLine().Trim());
            milestone1 = int.Parse(reader.ReadLine().Trim());
            milestone2 = int.Parse(reader.ReadLine().Trim());
            milestone3 = int.Parse(reader.ReadLine().Trim());
            milestone4 = int.Parse(reader.ReadLine().Trim());
            milestone5 = int.Parse(reader.ReadLine().Trim());
            milestone6 = int.Parse(reader.ReadLine().Trim());
            milestone7 = int.Parse(reader.ReadLine().Trim());
            milestone8 = int.Parse(reader.ReadLine().Trim());
            reader.Close();
        }

        /// <summary>
        /// Saves the configuration to persistent storage
        /// </summary>
        public static void Save()
        {
            StreamWriter writer = new StreamWriter(new FileStream(Application.StartupPath + "\\Nihonaid.config", FileMode.Create));
            writer.WriteLine(item_treshold);
            writer.WriteLine(todays_items);
            writer.WriteLine(last_session_date);
            writer.WriteLine(scheduler);
            writer.WriteLine(milestone1);
            writer.WriteLine(milestone2);
            writer.WriteLine(milestone3);
            writer.WriteLine(milestone4);
            writer.WriteLine(milestone5);
            writer.WriteLine(milestone6);
            writer.WriteLine(milestone7);
            writer.WriteLine(milestone8);
            writer.Close();
        }
    }
}